//
// Created by mouse on 2019/11/13.
//

#ifndef NODEMCU_LOG_H
#define NODEMCU_LOG_H

#include <Arduino.h>

class Log
{

public:
    Log();

    virtual ~Log()
    {}

    void d(const String &s)
    {
        if (this->isDebug)
        {
            Serial.println(s);
        }
    }

    void d(const char *format, ...)
    {
        if (this->isDebug)
        {
            va_list args;
            va_start(args, format);
            vprintf(format, args);
            va_end(args);
            Serial.printf(format, args);
        }
    }

    void setDebug(bool debug)
    {
        this->isDebug = debug;
    }

protected:
    bool isDebug = false;
};

extern Log logger;

#endif //NODEMCU_LOG_H
